﻿module Player

open Microsoft.Xna.Framework.Graphics
open Tile
open PathFinding


type Player = 
    {
        mColor               : Microsoft.Xna.Framework.Color
        mutable mPosition    : Tile
        mPathFinder          : PathFinder
        mutable mGoal        : Tile
        mutable mIsMoving    : bool
        mTrackID             : int
        mutable mGoalToCatch : int
    }

    static member InitPlayer(id, iPos, iFinder, iGoals, iGoal) = 
        let p = 
            {
                mColor          = id
                mPosition       = iPos
                mPathFinder     = iFinder
                mGoal           = iGoal
                mIsMoving       = false
                mTrackID        = -1
                mGoalToCatch    = iGoals
            }
        p

    member this.GoalCatched() = 
        if this.mGoal = this.mPosition then 
            true
        else
            false

    member this.ToStringColor() = 
        if (this.mColor = Microsoft.Xna.Framework.Color.Red) then
           "Red"
        else if (this.mColor = Microsoft.Xna.Framework.Color.Green) then
           "Green"
        else if (this.mColor = Microsoft.Xna.Framework.Color.Blue) then
           "Blue"
        else
           "White"

    member this.ToString() = 
        let color = this.ToStringColor()
        "Player " + color

